Enable the setting and trapping of breakpoints for hvm guest.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 31 Mar 2006 09:07:55 +0000 (10:07 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 31 Mar 2006 09:07:55 +0000 (10:07 +0100)
Catch Ctrl-C for gdbserver and let gdb break from continue command.

Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com>
tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/server.c
tools/libxc/xc_ptrace.c
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/support.h

index c987c0eb9d176d2542d8ee321a7d59436a6a92cf..3e1f50ea49f8943071fadc20a6621e2e31d4a9ad 100644 (file)
@@ -286,6 +286,21 @@ handle_v_requests (char *own_buf, char *status, unsigned char *signal)
   return;
 }
 
+void
+handle_breakpoint_requests (char *own_buf, char *status, unsigned char *signal)
+{
+  /*  Currently we only support software breakpoints */
+    switch (own_buf[1]) {
+        case '0': /* software breakpoint, int3 based */
+             own_buf[0] = '\0';
+            break;
+        case '1': /* hardware breakpoint */
+        default:
+                 write_enn (own_buf);
+            break;
+    }
+}
+
 void
 myresume (int step, int sig)
 {
@@ -322,6 +337,18 @@ gdbserver_usage (void)
         "HOST:PORT to listen for a TCP connection.\n");
 }
 
+extern control_c_pressed_flag;
+#include <signal.h>
+
+void ctrl_c_handler(int signo)
+{
+    printf("Ctrl-C pressed: Quit from the attached gdb first\n");
+    control_c_pressed_flag = 1;
+}
+
+struct sigaction ctrl_c_sigaction = { .sa_handler = ctrl_c_handler };
+struct sigaction old_sigaction;
+
 int
 main (int argc, char *argv[])
 {
@@ -396,9 +423,11 @@ main (int argc, char *argv[])
        }
     }
 
+
   while (1)
     {
       remote_open (argv[1]);
+      sigaction(SIGINT, &ctrl_c_sigaction, &old_sigaction);
 
     restart:
       setjmp (toplevel);
@@ -587,6 +616,9 @@ main (int argc, char *argv[])
              /* Extended (long) request.  */
              handle_v_requests (own_buf, &status, &signal);
              break;
+           case 'Z':
+             handle_breakpoint_requests (own_buf, &status, &signal);
+             break;
            default:
              /* It is a request we don't understand.  Respond with an
                 empty packet so that gdb knows that we don't support this
@@ -643,5 +675,6 @@ main (int argc, char *argv[])
                           "GDBserver will reopen the connection.\n");
          remote_close ();
        }
+    sigaction(SIGINT, &old_sigaction, NULL);
     }
 }
index f83005b45c01069c4364a26caf6a8d9872df9b78..30fe1db22e045e6e4dfeb271aa79199c239888c8 100644 (file)
@@ -401,6 +401,8 @@ map_domain_va(
     return map_domain_va_32(xc_handle, cpu, guest_va, perm);
 }
 
+int control_c_pressed_flag = 0;
+
 static int 
 __xc_waitdomain(
     int xc_handle,
@@ -419,7 +421,6 @@ __xc_waitdomain(
     op.cmd = DOM0_GETDOMAININFO;
     op.u.getdomaininfo.domain = domain;
     
-    
  retry:
     retval = do_dom0_op(xc_handle, &op);
     if ( retval || (op.u.getdomaininfo.domain != domain) )
@@ -432,12 +433,17 @@ __xc_waitdomain(
     if ( options & WNOHANG )
         goto done;
 
+    if (control_c_pressed_flag) {
+        xc_domain_pause(xc_handle, domain);
+        control_c_pressed_flag = 0;
+        goto done;
+    }
+
     if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) )
     {
         nanosleep(&ts,NULL);
         goto retry;
     }
-    /* XXX check for ^C here */
  done:
     if (get_online_cpumap(xc_handle, &op.u.getdomaininfo, &cpumap))
         printf("get_online_cpumap failed\n");
index 623fb22922383c92c6a3029d8749090f380e3263..5f7fa0221e53a8313f45260a0e7f406b14f54c37 100644 (file)
@@ -2130,6 +2130,14 @@ asmlinkage void vmx_vmexit_handler(struct cpu_user_regs regs)
 
             break;
         }
+        case TRAP_int3:
+        {
+            if ( test_bit(_DOMF_debugging, &v->domain->domain_flags) )
+                domain_pause_for_debugger();
+            else 
+                vmx_inject_exception(v, TRAP_int3, VMX_DELIVER_NO_ERROR_CODE);
+            break;
+        }
 #endif
         case TRAP_no_device:
         {
index 043754546a31a7b1e52e452a2fb145743d7c2258..22b24e392c557736d89f88973f85484b1924265c 100644 (file)
@@ -94,6 +94,7 @@ enum hval_bitmaps {
 #else
 #define MONITOR_DEFAULT_EXCEPTION_BITMAP        \
     ( EXCEPTION_BITMAP_PG |                     \
+      EXCEPTION_BITMAP_BP |                     \
       EXCEPTION_BITMAP_GP )
 #endif